import { createRouter, createWebHashHistory } from 'vue-router';
// import { useUserStore } from '@/store/user';

const routes = [
  {
    path: '/',
    name: 'home',
    component: () => import('@/views/home'),
    meta: {
      title: '首页',
      deepth: 1, //页面深度，当进入列表页不缓存列表页，从详情页返回列表页则缓存列表页用到，配合keepalive，深度越大数字越大
      keepAlive: false, //当前页面是否需要缓存
    },
  },
];

const router = createRouter({
  history: createWebHashHistory(),
  routes,
});

router.beforeEach((to, from, next) => {
  // const userStore = useUserStore();
  // let hasUser = userStore.info.uuid;
  // if (!hasUser) {
  //   next({ path: process.env.VUE_APP_LOGIN_PATH, query: { redirect: to.fullPath }, replace: true });
  // } else {
  //   next();
  // }
  next();
  document.title = to.meta.title;
});

export default router;
